/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package genericmetamodel.impl;

import genericmetamodel.Assets;
import genericmetamodel.Feature;
import genericmetamodel.GenericmetamodelPackage;
import genericmetamodel.Mapping;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Mapping</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link genericmetamodel.impl.MappingImpl#getName <em>Name</em>}</li>
 *   <li>{@link genericmetamodel.impl.MappingImpl#getDescription <em>Description</em>}</li>
 *   <li>{@link genericmetamodel.impl.MappingImpl#getFeatureMappingRef <em>Feature Mapping Ref</em>}</li>
 *   <li>{@link genericmetamodel.impl.MappingImpl#getAssetMappingRef <em>Asset Mapping Ref</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MappingImpl extends EObjectImpl implements Mapping {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected static final String DESCRIPTION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected String description = DESCRIPTION_EDEFAULT;

	/**
	 * The cached value of the '{@link #getFeatureMappingRef() <em>Feature Mapping Ref</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFeatureMappingRef()
	 * @generated
	 * @ordered
	 */
	protected Feature featureMappingRef;

	/**
	 * The cached value of the '{@link #getAssetMappingRef() <em>Asset Mapping Ref</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAssetMappingRef()
	 * @generated
	 * @ordered
	 */
	protected Assets assetMappingRef;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MappingImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return GenericmetamodelPackage.Literals.MAPPING;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GenericmetamodelPackage.MAPPING__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDescription(String newDescription) {
		String oldDescription = description;
		description = newDescription;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GenericmetamodelPackage.MAPPING__DESCRIPTION, oldDescription, description));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Feature getFeatureMappingRef() {
		if (featureMappingRef != null && featureMappingRef.eIsProxy()) {
			InternalEObject oldFeatureMappingRef = (InternalEObject)featureMappingRef;
			featureMappingRef = (Feature)eResolveProxy(oldFeatureMappingRef);
			if (featureMappingRef != oldFeatureMappingRef) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, GenericmetamodelPackage.MAPPING__FEATURE_MAPPING_REF, oldFeatureMappingRef, featureMappingRef));
			}
		}
		return featureMappingRef;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Feature basicGetFeatureMappingRef() {
		return featureMappingRef;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setFeatureMappingRef(Feature newFeatureMappingRef) {
		Feature oldFeatureMappingRef = featureMappingRef;
		featureMappingRef = newFeatureMappingRef;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GenericmetamodelPackage.MAPPING__FEATURE_MAPPING_REF, oldFeatureMappingRef, featureMappingRef));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Assets getAssetMappingRef() {
		if (assetMappingRef != null && assetMappingRef.eIsProxy()) {
			InternalEObject oldAssetMappingRef = (InternalEObject)assetMappingRef;
			assetMappingRef = (Assets)eResolveProxy(oldAssetMappingRef);
			if (assetMappingRef != oldAssetMappingRef) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, GenericmetamodelPackage.MAPPING__ASSET_MAPPING_REF, oldAssetMappingRef, assetMappingRef));
			}
		}
		return assetMappingRef;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Assets basicGetAssetMappingRef() {
		return assetMappingRef;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAssetMappingRef(Assets newAssetMappingRef) {
		Assets oldAssetMappingRef = assetMappingRef;
		assetMappingRef = newAssetMappingRef;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GenericmetamodelPackage.MAPPING__ASSET_MAPPING_REF, oldAssetMappingRef, assetMappingRef));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case GenericmetamodelPackage.MAPPING__NAME:
				return getName();
			case GenericmetamodelPackage.MAPPING__DESCRIPTION:
				return getDescription();
			case GenericmetamodelPackage.MAPPING__FEATURE_MAPPING_REF:
				if (resolve) return getFeatureMappingRef();
				return basicGetFeatureMappingRef();
			case GenericmetamodelPackage.MAPPING__ASSET_MAPPING_REF:
				if (resolve) return getAssetMappingRef();
				return basicGetAssetMappingRef();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case GenericmetamodelPackage.MAPPING__NAME:
				setName((String)newValue);
				return;
			case GenericmetamodelPackage.MAPPING__DESCRIPTION:
				setDescription((String)newValue);
				return;
			case GenericmetamodelPackage.MAPPING__FEATURE_MAPPING_REF:
				setFeatureMappingRef((Feature)newValue);
				return;
			case GenericmetamodelPackage.MAPPING__ASSET_MAPPING_REF:
				setAssetMappingRef((Assets)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case GenericmetamodelPackage.MAPPING__NAME:
				setName(NAME_EDEFAULT);
				return;
			case GenericmetamodelPackage.MAPPING__DESCRIPTION:
				setDescription(DESCRIPTION_EDEFAULT);
				return;
			case GenericmetamodelPackage.MAPPING__FEATURE_MAPPING_REF:
				setFeatureMappingRef((Feature)null);
				return;
			case GenericmetamodelPackage.MAPPING__ASSET_MAPPING_REF:
				setAssetMappingRef((Assets)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case GenericmetamodelPackage.MAPPING__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case GenericmetamodelPackage.MAPPING__DESCRIPTION:
				return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
			case GenericmetamodelPackage.MAPPING__FEATURE_MAPPING_REF:
				return featureMappingRef != null;
			case GenericmetamodelPackage.MAPPING__ASSET_MAPPING_REF:
				return assetMappingRef != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (Name: ");
		result.append(name);
		result.append(", Description: ");
		result.append(description);
		result.append(')');
		return result.toString();
	}

} //MappingImpl
